package mahjong.auto.com.automahjong;

import android.app.Application;
import android.content.Intent;
import android.media.projection.MediaProjectionManager;
import android.os.Handler;

import mahjong.auto.com.os.Mahjong;

/**
 * Created by heqian on 17-7-28.
 */

public class App extends Application {
    private static App application = null;
    private Handler handler = null;
    private ScreenCapture capture = null;

    public ScreenCapture getCapture() {
        return capture;
    }

    public void setCapture(ScreenCapture capture) {
        this.capture = capture;
    }

    public static App getApp() {
        return application;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        Mahjong.init();
        startService(new Intent(this, AppService.class));
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        Mahjong.destroy();
    }

    public void start() {
        if (null != handler) {
            handler.sendEmptyMessage(AppService.STATUS_START);
        }
    }

    public void stop() {
        if (null != handler) {
            handler.sendEmptyMessage(AppService.STATUS_STOP);
        }
    }

    public void setHandler(Handler handler) {
        this.handler = handler;
    }

    public Handler getHandler() {
        return handler;
    }
}
